package com.example.otalib.boads;

public class LoaderCrc {
    final static int[] crc16tab;
    
    static {
        int[] a = new int[256];
        a[0] = 0;
        a[1] = 4129;
        a[2] = 8258;
        a[3] = 12387;
        a[4] = 16516;
        a[5] = 20645;
        a[6] = 24774;
        a[7] = 28903;
        a[8] = 33032;
        a[9] = 37161;
        a[10] = 41290;
        a[11] = 45419;
        a[12] = 49548;
        a[13] = 53677;
        a[14] = 57806;
        a[15] = 61935;
        a[16] = 4657;
        a[17] = 528;
        a[18] = 12915;
        a[19] = 8786;
        a[20] = 21173;
        a[21] = 17044;
        a[22] = 29431;
        a[23] = 25302;
        a[24] = 37689;
        a[25] = 33560;
        a[26] = 45947;
        a[27] = 41818;
        a[28] = 54205;
        a[29] = 50076;
        a[30] = 62463;
        a[31] = 58334;
        a[32] = 9314;
        a[33] = 13379;
        a[34] = 1056;
        a[35] = 5121;
        a[36] = 25830;
        a[37] = 29895;
        a[38] = 17572;
        a[39] = 21637;
        a[40] = 42346;
        a[41] = 46411;
        a[42] = 34088;
        a[43] = 38153;
        a[44] = 58862;
        a[45] = 62927;
        a[46] = 50604;
        a[47] = 54669;
        a[48] = 13907;
        a[49] = 9842;
        a[50] = 5649;
        a[51] = 1584;
        a[52] = 30423;
        a[53] = 26358;
        a[54] = 22165;
        a[55] = 18100;
        a[56] = 46939;
        a[57] = 42874;
        a[58] = 38681;
        a[59] = 34616;
        a[60] = 63455;
        a[61] = 59390;
        a[62] = 55197;
        a[63] = 51132;
        a[64] = 18628;
        a[65] = 22757;
        a[66] = 26758;
        a[67] = 30887;
        a[68] = 2112;
        a[69] = 6241;
        a[70] = 10242;
        a[71] = 14371;
        a[72] = 51660;
        a[73] = 55789;
        a[74] = 59790;
        a[75] = 63919;
        a[76] = 35144;
        a[77] = 39273;
        a[78] = 43274;
        a[79] = 47403;
        a[80] = 23285;
        a[81] = 19156;
        a[82] = 31415;
        a[83] = 27286;
        a[84] = 6769;
        a[85] = 2640;
        a[86] = 14899;
        a[87] = 10770;
        a[88] = 56317;
        a[89] = 52188;
        a[90] = 64447;
        a[91] = 60318;
        a[92] = 39801;
        a[93] = 35672;
        a[94] = 47931;
        a[95] = 43802;
        a[96] = 27814;
        a[97] = 31879;
        a[98] = 19684;
        a[99] = 23749;
        a[100] = 11298;
        a[101] = 15363;
        a[102] = 3168;
        a[103] = 7233;
        a[104] = 60846;
        a[105] = 64911;
        a[106] = 52716;
        a[107] = 56781;
        a[108] = 44330;
        a[109] = 48395;
        a[110] = 36200;
        a[111] = 40265;
        a[112] = 32407;
        a[113] = 28342;
        a[114] = 24277;
        a[115] = 20212;
        a[116] = 15891;
        a[117] = 11826;
        a[118] = 7761;
        a[119] = 3696;
        a[120] = 65439;
        a[121] = 61374;
        a[122] = 57309;
        a[123] = 53244;
        a[124] = 48923;
        a[125] = 44858;
        a[126] = 40793;
        a[127] = 36728;
        a[128] = 37256;
        a[129] = 33193;
        a[130] = 45514;
        a[131] = 41451;
        a[132] = 53516;
        a[133] = 49453;
        a[134] = 61774;
        a[135] = 57711;
        a[136] = 4224;
        a[137] = 161;
        a[138] = 12482;
        a[139] = 8419;
        a[140] = 20484;
        a[141] = 16421;
        a[142] = 28742;
        a[143] = 24679;
        a[144] = 33721;
        a[145] = 37784;
        a[146] = 41979;
        a[147] = 46042;
        a[148] = 49981;
        a[149] = 54044;
        a[150] = 58239;
        a[151] = 62302;
        a[152] = 689;
        a[153] = 4752;
        a[154] = 8947;
        a[155] = 13010;
        a[156] = 16949;
        a[157] = 21012;
        a[158] = 25207;
        a[159] = 29270;
        a[160] = 46570;
        a[161] = 42443;
        a[162] = 38312;
        a[163] = 34185;
        a[164] = 62830;
        a[165] = 58703;
        a[166] = 54572;
        a[167] = 50445;
        a[168] = 13538;
        a[169] = 9411;
        a[170] = 5280;
        a[171] = 1153;
        a[172] = 29798;
        a[173] = 25671;
        a[174] = 21540;
        a[175] = 17413;
        a[176] = 42971;
        a[177] = 47098;
        a[178] = 34713;
        a[179] = 38840;
        a[180] = 59231;
        a[181] = 63358;
        a[182] = 50973;
        a[183] = 55100;
        a[184] = 9939;
        a[185] = 14066;
        a[186] = 1681;
        a[187] = 5808;
        a[188] = 26199;
        a[189] = 30326;
        a[190] = 17941;
        a[191] = 22068;
        a[192] = 55628;
        a[193] = 51565;
        a[194] = 63758;
        a[195] = 59695;
        a[196] = 39368;
        a[197] = 35305;
        a[198] = 47498;
        a[199] = 43435;
        a[200] = 22596;
        a[201] = 18533;
        a[202] = 30726;
        a[203] = 26663;
        a[204] = 6336;
        a[205] = 2273;
        a[206] = 14466;
        a[207] = 10403;
        a[208] = 52093;
        a[209] = 56156;
        a[210] = 60223;
        a[211] = 64286;
        a[212] = 35833;
        a[213] = 39896;
        a[214] = 43963;
        a[215] = 48026;
        a[216] = 19061;
        a[217] = 23124;
        a[218] = 27191;
        a[219] = 31254;
        a[220] = 2801;
        a[221] = 6864;
        a[222] = 10931;
        a[223] = 14994;
        a[224] = 64814;
        a[225] = 60687;
        a[226] = 56684;
        a[227] = 52557;
        a[228] = 48554;
        a[229] = 44427;
        a[230] = 40424;
        a[231] = 36297;
        a[232] = 31782;
        a[233] = 27655;
        a[234] = 23652;
        a[235] = 19525;
        a[236] = 15522;
        a[237] = 11395;
        a[238] = 7392;
        a[239] = 3265;
        a[240] = 61215;
        a[241] = 65342;
        a[242] = 53085;
        a[243] = 57212;
        a[244] = 44955;
        a[245] = 49082;
        a[246] = 36825;
        a[247] = 40952;
        a[248] = 28183;
        a[249] = 32310;
        a[250] = 20053;
        a[251] = 24180;
        a[252] = 11923;
        a[253] = 16050;
        a[254] = 3793;
        a[255] = 7920;
        crc16tab = a;
    }
    
    public LoaderCrc() {
    }
    
    public static byte[] crc16_ccitt(byte[] a, int i, int i0) {
        byte[] a0 = new byte[2];
        int i1 = i + 0;
        int i2 = 0;
        for(; i1 < i0 + i; i1 = i1 + 1) {
            int i3 = i2 << 8;
            i2 = crc16tab[(i2 >> 8 ^ (int)a[i1]) & 255] ^ i3;
        }
        a0[0] = (byte)(int)(byte)(i2 & 255);
        a0[1] = (byte)(int)(byte)(i2 >> 8 & 255);
        return a0;
    }
}
